package org.ihelpuoo.weboo.security;

import org.ihelpuoo.lang.ArrayUtils;
import org.ihelpuoo.lang.StringUtils;
import org.ihelpuoo.weboo.exception.DispathException;
import org.ihelpuoo.weboo.module.ActionContext;

public class LoginSessionController extends SessionController<String>
{

	@Override
	protected boolean iNeedDoCheck(ActionContext context) throws DispathException
	{
		if (context.getSession().isLogined())
			return false;
		return true;
	}

	@Override
	protected String[] parseConifgItem(ActionContext context, String value)
	{
		if (StringUtils.isEmpty(value))
			return new String[0];
		return StringUtils.splitIgnoreBlank(value);
	}

	@Override
	protected String doCheck(ActionContext context, String[] items) throws Exception
	{
		if (ArrayUtils.isInArray(items,context.getActionnName()))
			return Security.me(context.nut()).getFailTarget();
		return null;
	}

}
